<template>
  <div class="order">
    <el-header style="position: relative">
      <span style="font-size: 30px;font-family: '楷体';color: #55a1ff "><i class=""></i>&nbsp;&nbsp;用户订单详情 </span>
    </el-header>
    <el-main style="overflow-y: scroll;max-height: 650px">
      <el-timeline :reverse="reverse">
        <el-timeline-item  v-for="(item,index) in order" :timestamp="item.createTime" placement="top">
        <el-card class="box-card" style="margin-top: 20px;">
          <div slot="header" class="clearfix">
            <span style="font-family: Agency FB;;font-size: 20px">购买人： {{item.userId}} &nbsp; &nbsp;&nbsp; &nbsp; 总价为： {{item.allPrice}} <i class="fa fa-jpy" aria-hidden="true"></i></span>

          </div>
            <div class="text item">
            <el-table :data="item.cartVOS">
              <el-table-column type="index" label="编号"
                               width="150"></el-table-column>
              <el-table-column label="图片" width="150">
                <template slot-scope="scope">
                  <!--scope.row代表当前遍历的数组中的对象-->
                  <el-image style="width:90px;height: 50px" :src="scope.row.vegetableImage"></el-image>
                </template>
              </el-table-column>
              <el-table-column label="菜品名" prop="vegetableName" width="200"></el-table-column>
              <el-table-column label="单价" prop="vegetablePrice" width="200"></el-table-column>
              <el-table-column label="购买数量" prop="cartCount" width="200"></el-table-column>
            </el-table>
          </div>
        </el-card>
        </el-timeline-item>
      </el-timeline>
    </el-main>
  </div>
</template>

<script>

import {getOrderDetail} from "@/api/admin_api";
import {WorkUser} from "@/api/admin_api";

export default {
  name: "order_list",
  data(){
    return{
      order:[
      ],
      userName:[]

    }
  },
  created() {
    getOrderDetail().then((res)=>{
      this.order = res.data.data;
      for (let i = 0;i<this.order.length;i++){
        WorkUser(this.order[i].userId).then((res)=>{
         this.order[i].userId = res.data.data.userName
        })
      }
    })





  }
}
</script>

<style scoped>
.order .text {
  font-size: 14px;
}

.order .item {
  margin-bottom: 18px;
}

.order .clearfix:before,
.order .clearfix:after {
  display: table;
  content: "";
}
.order .clearfix:after {
  clear: both
}

.order .box-card {
  width: 90%;
}
</style>